var GameData = require('../module/gameData')();
cc.Class({
    extends: cc.Component,

    properties: {
        moveMusic: {
            default: [],
            type: [cc.AudioClip]
        },

    },


    onLoad() {
        GameData.playMusic(this.moveMusic[0], true);
        GameData.upgradehomeScene = this;
        GameData.enter();
        switch (GameData.gameUpgrade) {
            case 1:
                cc.find("Canvas/up_shui").active = true;
                cc.find("Canvas/up_zidan").active = false;
                cc.find("Canvas/up_luck").active = false;
                cc.find("watchTv").active = false;

                break;
            case 2:
                cc.find("Canvas/up_shui").active = false;
                cc.find("Canvas/up_zidan").active = true;
                cc.find("Canvas/up_luck").active = false;
                cc.find("watchTv").active = false;
                break;
            case 3:
                cc.find("Canvas/up_shui").active = false;
                cc.find("Canvas/up_zidan").active = false;

                cc.find("Canvas/up_luck").active = true;
                cc.find("watchTv").active = false;
                break;
        }
    },
    goback() {
        if (GameData.gamhomeshow) {
            this.fishData = GameData.getlocalData("fishData");
            var _num2 = GameData.upgradeData.box[this.fishData.upgrade.box - 1].Allnum;
            var _num1 = this.fishData.handbook.oldfish.length;
            if (_num2 <= _num1) {
                this.fishData.handbook.newfish = [];
                GameData.savelocalData(this.fishData);
            } else {
                console.log("新鱼转老鱼", this.fishData.handbook.newfish[0])
                this.fishData.handbook.oldfish.push( this.fishData.handbook.newfish[0]);
                console.log(this.fishData.handbook.newfish[0]);
                this.fishData.handbook.newfish.splice(0, 1);
                GameData.savelocalData(this.fishData);
            }
        }
        cc.director.preloadScene("Home", function () {
            GameData.stopMusic();
            cc.director.loadScene("Home");
        });
    },
    start() {

    },
    onDestroy() {
        GameData.upgradehomeScene = null;
    },
    update(dt) {
        GameData.playTime += dt;
    },
});
